package view.main;

import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import view.combo.V_Combo;
import view.combo.V_comboShow;
import view.dic.V_Dictionary;
import view.menu.V_menuManage;
import view.orderfood.V_order;
import view.settlement.V_Pay;
import view.table.V_tableAdd;
import view.table.V_tables;
import view.vip.V_vipMain;
import view.waiters.waiter;

public class BtnActionListener implements ActionListener {

	 static JTabbedPane tab = new JTabbedPane(JTabbedPane.TOP);
//	public BtnActionListener() {
//		this.tab = new JTabbedPane(JTabbedPane.TOP);
//	}
	 private static V_Pay pay;
	 
	public static V_Pay getPay() {
		return pay;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
		JButton btn = (JButton) e.getSource();//获取点击的按钮
		MainMenu_new.contentPane.add(tab, BorderLayout.NORTH);

		
		switch (btn.getText()) {
		
		case "日常事务":
			tab.removeAll();
			pay = new V_Pay();
			System.out.println("进入日常事务监听1");
			JTabbedPane cai = new JTabbedPane(JTabbedPane.LEFT);
			cai.addTab("点餐", null, new V_order().getContentPane(), null);
			System.out.println("进入日常事务监听2");
			cai.addTab("选桌", null, new V_tables().getContentPane(), null);
			cai.addTab("结算", null, pay.getContentPane(), null);
			tab.addTab("点餐/用餐", null, cai, null);

			JTabbedPane cai2 = new JTabbedPane(JTabbedPane.LEFT);
			cai2.addTab("套餐选菜", null, new V_Combo().getContentPane(), null);
			cai2.addTab("套餐管理", null, new V_comboShow().getContentPane(), null);
			cai2.addTab("添加菜", null, new V_menuManage().getContentPane(), null);
			tab.addTab("菜品管理", null, cai2, null);
			
			tab.addTab("数据字典", null, new V_Dictionary().getContentPane(), null);
			System.out.println("进入日常事务监听--------");
			tab.updateUI();//刷新一下加的东西
			
			break;
		case "人员管理":
			
			tab.removeAll();
//			JPanel panel_4 = new JPanel();
			tab.addTab("会员管理", null,new V_vipMain().getContentPane(), null);
//			JPanel panel_5 = new JPanel();
			tab.addTab("服务员管理", null, new waiter().getContentPane(), null);
			
			tab.addTab("桌子管理", null, new V_tableAdd().getContentPane(), null);
			
			tab.updateUI();//更新一下加的东西
			break;
			
		case "软件教程":
//			String dir = System.getProperty("user.dir"); 
			try {
				Desktop.getDesktop().open(new File("help/help.txt"));//打开文件
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			
			break;
			
		default:
			break;
		}
		
	}

}
